using Common.Commands;
using Common.Commands.ContactCommands;
using Core.Domain.Model;
using Sanelib.DataOperation;
using Sanelib.Dto;

namespace Core.Processors.ContactProcessors
{
	public class DeleteContactProcessor : ICommandProcessor<DeleteContact>
	{
		private readonly IRepository<Contact> _contactRepository;

		public DeleteContactProcessor(IRepository<Contact> contactRepository)
		{
		    _contactRepository = contactRepository;
		}

	    public dynamic Process(DeleteContact command)
 		{
			var response = new WebApiResultResponse();
			var contact = _contactRepository.GetById(command.Id);
			_contactRepository.Delete(contact.Id);
			response.IsSuccess = true;
			return response;
		}
	}
}
